<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('学员成绩')"/>
    <th:block th:include="include :: select2-css"/>

    <style>
        .score-div{
            width: 245px;
            min-height: 250px;
            background-color: rgba(0, 0, 0, 0.13);
            margin: 10px;
            padding: 6px;
            border-radius: 10px;
        }
        .historyScore{
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
        }

    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="col-sm-12 search-collapse" style="background: rgba(255,255,255,0)">
        <form id="data-form">
            <input id="childId" name="childId" th:value="*{childId}" hidden="true">
            <input id="projectCode" name="projectCode" th:value="*{projectCode}" hidden="true">
            <div class="row historyScore" id="historyScore" style="">

            </div>

        </form>
    </div>

</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">
    // 权限
    // 字典
    var prefix = ctx + "business/courseChildScore";

    $(function () {
        $.ajax({
            url: prefix + "/listHistoryScore?childId=" + $("#childId").val()+"&projectCode="+$("#projectCode").val(),
            type: 'GET',
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                console.log(data);
                if(data.data.length >0){
                    for(var i in data.data){
                        $("#historyScore").append(formatScore(data.data[i]));
                    }

                }
            }
        });

    });


    function formatScore(row) {
        var html="<div><lable style='margin-left: 18px;font-size: 14px;'>"+row.dayDate+"</lable>";
        html+= "<div class='score-div'>";
        var projectName =row['projectName'];
        var projectCode = row['projectCode']
        var question =row['projectQuestion']==""?"":JSON.parse(row['projectQuestion']);
        var score =(row['projectScore']=="" || row['projectScore']=="{}")?"":JSON.parse(row['projectScore']);
        if(question==""){
            return "";
        }
        html+="<label style='font-size: 16px;font-weight: bold'>"+projectName+"</label><br>";
        var temp="";
        for(var i in question){
            var obj = question[i];
            if(score !=null && score !=''){
                temp = score[obj.key];
                if(temp!=undefined && temp !="" && obj.type=='checkBox'){
                    temp=(temp=="on" ?"是":"否");
                }
                if(temp!=undefined && temp !="" && obj.type=='select'){
                    for(var k in obj.option){
                        if(temp == obj.option[k].value){
                            temp = obj.option[k].text;
                            break;
                        }
                    }
                }
            }
            if(temp ==undefined){
                temp ="";
            }
            html+="<label>"+obj.lable+"："+temp+"</label><br>";
        }

        html += "</div></div>";
        return html;
    }




</script>
</body>

</html>